#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,ans,l[1000010],ans1;
pair<bool,bool> c={1,1};
struct car{
    int d,v,a;
    double s,e;
}a[100010];
struct mec{
    int d,c;
}p[100010];
void init(){
    cin>>n>>m>>L>>V;
    for(int i=1;i<=n;i++){
        cin>>a[i].d>>a[i].v>>a[i].a;
        if(a[i].a<0) c.first=c.second=0;
        else if(a[i].a==0) c.second=0;
        else if(a[i].a>0) c.first=0;
        if(a[i].a==0&&a[i].v>V) a[i].s=a[i].d,a[i].e=L,ans++;
        if(a[i].a>0&&sqrt(double(a[i].v*a[i].v+2*a[i].a*(p[m].d-a[i].d)))>V)
            a[i].s=(V*V-a[i].v*a[i].v)*1.0/(2*a[i].a),a[i].e=L,ans++;
        if(a[i].a<0&&a[i].v>V) a[i].s=a[i].d,a[i].e=(V*V-a[i].v*a[i].v)*1.0/(2*a[i].a),ans++;
    }
    for(int i=1;i<=m;i++) cin>>p[i].d;
}
void T34(){
    int ans=0;
    for(int i=1;i<=n;i++)
        if(a[i].v>V&&a[i].d<=p[m].d) ans++;
    cout<<ans<<" "<<m-1<<"\n";
    return;
}
void T56(){
    int ans=0;
    for(int i=1;i<=n;i++)
      if(sqrt(double(a[i].v*a[i].v*1.0+2*a[i].a*(p[m].d-a[i].d)*1.0)*1.0)>V&&a[i].d<=p[m].d) ans++;
    cout<<ans<<" "<<m-1<<"\n";
    return;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int d=1;d<=T;d++){
        init();
        if(c.first) T34();
        else if(c.second) T56();
        else{
            for(int i=1;i<=n;i++)
                for(int j=ceil(a[i].s*1.0);j<=floor(a[i].e*1.0);j++) l[j]++;
            int mm=INT_MIN;
            for(int i=1;i<=m;i++)
                p[i].c=l[p[i].d],mm=max(mm,p[i].c);
            for(int i=1;i<=n;i++)
                if(p[i].c==mm) ans1++;
            cout<<ans<<" "<<m-ans1<<"\n";
        }
    }
    fclose(stdin);
    fclose(stdout);

    return 0;
}
